package org.imac.quizz;

import android.app.Activity;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.drawable.StateListDrawable;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;


public class QuizzActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        Resources res = getResources();
        StateListDrawable boutonPlay = new StateListDrawable();
        boutonPlay.addState(new int[] {android.R.attr.state_pressed}, res.getDrawable(R.drawable.button2));
        boutonPlay.addState(new int[] {}, res.getDrawable(R.drawable.button1));
        
        ((Button)findViewById(R.id.mybutton2)).setBackgroundDrawable(boutonPlay);
        
        ((Button)findViewById(R.id.mybutton2)).setOnClickListener(new View.OnClickListener() {
        	
            public void onClick(View v) {
            	Intent intent = new Intent(QuizzActivity.this, InscriptionActivity.class);
            	startActivity(intent);
            }
        });

    }
    public boolean onCreateOptionsMenu(Menu menu){
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.xml.menu, menu);
        return true;
     }
     // Called when menu item is selected 
     public boolean onOptionsItemSelected(MenuItem item){
        switch(item.getItemId()){
        case R.id.itemPrefs:
          // Launch Prefs activity
          Intent i = new Intent(QuizzActivity.this, PreferenceQuizz.class);
          startActivity(i);
          break;
        case R.id.itemNotice:
            // Launch Prefs activity
            Intent j = new Intent(QuizzActivity.this, NoticeQuizz.class);
            startActivity(j);
            break;
        }
        return true;
     }
}     
